# SPDX-License-Identifier: Apache-2.0
"""
Update TEXT to str

Revision ID: 8eee7a6fa93a
Revises: b985bb544962
Create Date: 2023-09-08 19:14:24.978213
"""

import sqlalchemy as sa

from alembic import op

revision = "8eee7a6fa93a"
down_revision = "b985bb544962"


def upgrade():
    op.alter_column(
        "admin_flags",
        "id",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=False,
    )
    op.alter_column(
        "admin_flags",
        "description",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=False,
    )
    op.alter_column(
        "banners",
        "text",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=False,
    )
    op.alter_column(
        "banners",
        "link_url",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=False,
    )
    op.alter_column(
        "ip_addresses",
        "hashed_ip_address",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_comment="Hash that represents an IP Address",
        existing_nullable=True,
    )
    op.alter_column(
        "organization_applications",
        "name",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_comment="The account name used in URLS",
        existing_nullable=False,
    )
    op.alter_column(
        "organization_applications",
        "display_name",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_comment="Display name used in UI",
        existing_nullable=False,
    )
    op.alter_column(
        "organization_applications",
        "link_url",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_comment="External URL associated with the organization",
        existing_nullable=False,
    )
    op.alter_column(
        "organization_applications",
        "description",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_comment="Description of the business or project the organization represents",  # noqa
        existing_nullable=False,
    )
    op.alter_column(
        "organization_invitations",
        "token",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=False,
    )
    op.alter_column(
        "organization_name_catalog",
        "normalized_name",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=False,
    )
    op.alter_column(
        "organizations",
        "name",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_comment="The account name used in URLS",
        existing_nullable=False,
    )
    op.alter_column(
        "organizations",
        "display_name",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_comment="Display name used in UI",
        existing_nullable=False,
    )
    op.alter_column(
        "organizations",
        "link_url",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_comment="External URL associated with the organization",
        existing_nullable=False,
    )
    op.alter_column(
        "organizations",
        "description",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_comment="Description of the business or project the organization represents",  # noqa
        existing_nullable=False,
    )
    op.alter_column(
        "prohibited_user_names",
        "name",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=False,
    )
    op.alter_column(
        "prohibited_user_names",
        "comment",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=False,
        existing_server_default=sa.text("''::text"),
    )
    op.alter_column(
        "projects",
        "sitemap_bucket",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=False,
    )
    op.alter_column(
        "row_counts",
        "table_name",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=False,
    )
    op.alter_column(
        "ses_emails",
        "message_id",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=False,
    )
    op.alter_column(
        "ses_emails",
        "from",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=False,
    )
    op.alter_column(
        "ses_emails",
        "to",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=False,
    )
    op.alter_column(
        "ses_emails",
        "subject",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=False,
    )
    op.alter_column(
        "ses_events",
        "event_id",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=False,
    )
    op.alter_column(
        "sponsors",
        "activity_markdown",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=True,
    )
    op.alter_column(
        "sponsors",
        "link_url",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=False,
    )
    op.alter_column(
        "sponsors",
        "color_logo_url",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=False,
    )
    op.alter_column(
        "sponsors",
        "white_logo_url",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=True,
    )
    op.alter_column(
        "stripe_customers",
        "customer_id",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=False,
    )
    op.alter_column(
        "stripe_customers",
        "billing_email",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=True,
    )
    op.alter_column(
        "stripe_subscription_items",
        "subscription_item_id",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=True,
    )
    op.alter_column(
        "stripe_subscription_prices",
        "price_id",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=True,
    )
    op.alter_column(
        "stripe_subscription_prices",
        "currency",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=False,
    )
    op.alter_column(
        "stripe_subscription_prices",
        "tax_behavior",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=True,
    )
    op.alter_column(
        "stripe_subscription_products",
        "product_id",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=True,
    )
    op.alter_column(
        "stripe_subscription_products",
        "product_name",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=False,
    )
    op.alter_column(
        "stripe_subscription_products",
        "description",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=False,
    )
    op.alter_column(
        "stripe_subscription_products",
        "tax_code",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=True,
    )
    op.alter_column(
        "stripe_subscriptions",
        "subscription_id",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=False,
    )
    op.alter_column(
        "teams",
        "name",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=False,
    )
    op.alter_column(
        "trove_classifiers",
        "classifier",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=True,
    )
    op.alter_column(
        "users",
        "sitemap_bucket",
        existing_type=sa.TEXT(),
        type_=sa.String(),
        existing_nullable=False,
    )


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column(
        "users",
        "sitemap_bucket",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=False,
    )
    op.alter_column(
        "trove_classifiers",
        "classifier",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=True,
    )
    op.alter_column(
        "teams",
        "name",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=False,
    )
    op.alter_column(
        "stripe_subscriptions",
        "subscription_id",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=False,
    )
    op.alter_column(
        "stripe_subscription_products",
        "tax_code",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=True,
    )
    op.alter_column(
        "stripe_subscription_products",
        "description",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=False,
    )
    op.alter_column(
        "stripe_subscription_products",
        "product_name",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=False,
    )
    op.alter_column(
        "stripe_subscription_products",
        "product_id",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=True,
    )
    op.alter_column(
        "stripe_subscription_prices",
        "tax_behavior",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=True,
    )
    op.alter_column(
        "stripe_subscription_prices",
        "currency",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=False,
    )
    op.alter_column(
        "stripe_subscription_prices",
        "price_id",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=True,
    )
    op.alter_column(
        "stripe_subscription_items",
        "subscription_item_id",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=True,
    )
    op.alter_column(
        "stripe_customers",
        "billing_email",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=True,
    )
    op.alter_column(
        "stripe_customers",
        "customer_id",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=False,
    )
    op.alter_column(
        "sponsors",
        "white_logo_url",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=True,
    )
    op.alter_column(
        "sponsors",
        "color_logo_url",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=False,
    )
    op.alter_column(
        "sponsors",
        "link_url",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=False,
    )
    op.alter_column(
        "sponsors",
        "activity_markdown",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=True,
    )
    op.alter_column(
        "ses_events",
        "event_id",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=False,
    )
    op.alter_column(
        "ses_emails",
        "subject",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=False,
    )
    op.alter_column(
        "ses_emails",
        "to",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=False,
    )
    op.alter_column(
        "ses_emails",
        "from",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=False,
    )
    op.alter_column(
        "ses_emails",
        "message_id",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=False,
    )
    op.alter_column(
        "row_counts",
        "table_name",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=False,
    )
    op.alter_column(
        "projects",
        "sitemap_bucket",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=False,
    )
    op.alter_column(
        "prohibited_user_names",
        "comment",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=False,
        existing_server_default=sa.text("''::text"),
    )
    op.alter_column(
        "prohibited_user_names",
        "name",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=False,
    )
    op.alter_column(
        "organizations",
        "description",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_comment="Description of the business or project the organization represents",  # noqa
        existing_nullable=False,
    )
    op.alter_column(
        "organizations",
        "link_url",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_comment="External URL associated with the organization",
        existing_nullable=False,
    )
    op.alter_column(
        "organizations",
        "display_name",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_comment="Display name used in UI",
        existing_nullable=False,
    )
    op.alter_column(
        "organizations",
        "name",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_comment="The account name used in URLS",
        existing_nullable=False,
    )
    op.alter_column(
        "organization_name_catalog",
        "normalized_name",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=False,
    )
    op.alter_column(
        "organization_invitations",
        "token",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=False,
    )
    op.alter_column(
        "organization_applications",
        "description",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_comment="Description of the business or project the organization represents",  # noqa
        existing_nullable=False,
    )
    op.alter_column(
        "organization_applications",
        "link_url",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_comment="External URL associated with the organization",
        existing_nullable=False,
    )
    op.alter_column(
        "organization_applications",
        "display_name",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_comment="Display name used in UI",
        existing_nullable=False,
    )
    op.alter_column(
        "organization_applications",
        "name",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_comment="The account name used in URLS",
        existing_nullable=False,
    )
    op.alter_column(
        "ip_addresses",
        "hashed_ip_address",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_comment="Hash that represents an IP Address",
        existing_nullable=True,
    )
    op.alter_column(
        "banners",
        "link_url",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=False,
    )
    op.alter_column(
        "banners",
        "text",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=False,
    )
    op.alter_column(
        "admin_flags",
        "description",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=False,
    )
    op.alter_column(
        "admin_flags",
        "id",
        existing_type=sa.String(),
        type_=sa.TEXT(),
        existing_nullable=False,
    )
